perm filename CHAP10.TEX[WEB,ALS] blob sn#690216 filedate 1982-12-15 generic text, type T, neo UTF8
\chapterbegin Chapter 10. Dimensions

Sometimes you want to tell \TeX\ how big to make a space, or how wide to
make a line. For example, the short story of Chapter@6 used the instruction
`|\vskip .5cm|' to skip vertically by half a centimeter, and we also
said `|\hsize=4in|' to specify a horizontal size of 4@inches. It's time now
to consider the various ways such ↑{dimensions} can be communicated to \TeX.

``↑{Points}'' and ``↑{picas}'' are the traditional units of measure for
printers in English-speaking countries, so \TeX\ understands points and
picas. \TeX\ also understands inches and metric units, as well as the
continental European versions of points and picas. Each unit of measure
is given a two-letter abbreviation, as follows:
$$\halign{\indent\tt#&\quad#\hfil\cr
pt&point (baselines in this manual are $12\pt$ apart)\cr
pc&pica ($\rm1{pc}=12{pt}$)\cr
in&inch ($\rm1{in}=72.27{pt}$)\cr
bp&big point ($\rm72{bp}=1{in}$)\cr
cm¢imeter ($\rm2.54{cm}=1{in}$)\cr
mm&millimeter ($\rm10{mm}=1{cm}$)\cr
dd&did\↑ot point ($\rm1157{dd}=1238{pt}$)\cr
cc&cicero ($\rm1{cc}=12{dd}$)\cr
sp&scaled point ($\rm65536{sp}=1{pt}$)\cr}$$
↑(.pt)↑(point)
↑(.pc)↑(pica)
↑(.in)↑(inch)
↑(.bp)↑(big point)
↑(.cm)↑(centimeter)
↑(.mm)↑(millimeter)
↑(.dd)↑(did\↑ot point)↑(Did\↑ot, Fran\c cois Ambroise)
↑(.cc)↑(cicero)
↑(.sp)↑(scaled point)
The output of \TeX\ is firmly grounded in the metric system, using the
conversion factors shown here as exact ratios.

\exercise How many points are there in 254 centimeters?
\answer Exactly $7227\pt$.

When you want to express some physical dimension to \TeX, type it as
$$\displaybox{\<optional sign>\<number>\<unit of measure>}$$
or
$$\displaybox{\<optional sign>\<digit string>|.|\<digit string>\<unit
  of measure>}$$
where an ↑{<optional sign} is either a `|+|' or a `|-|' or nothing at all,
and where a ↑{<digit string} consists of zero or more consecutive
decimal digits. For example, here are some typical dimensions:
$$\halign{\indent#\hfil&\hskip 6em#\hfil\cr
|3 in|&|29 pc|\cr
|-.013837in|&|+ 42.1 dd|\cr
|0.mm|&|123456789sp|\cr}$$
A plus sign is redundant, but some people occasionally like extra
redundancy once in awhile. Blank spaces are optional before the signs and the
numbers and the units of measure, and you can also put an optional space
after the dimension; but you should not put spaces within the digits
of a number or between the letters of the unit of measure.

\exercise Arrange those six ``typical dimensions'' into order,
from smallest to largest.
\answer $\rm-.013837{in}$, $\rm0.{mm}$, $\rm+42.1{dd}$, $\rm3{in}$,
$\rm29{pc}$, $\rm123456789{sp}$.
\ (The lines of text in this manual are 29@picas wide.)

\dangerexercise Two of the following three dimensions are legitimate
according to \TeX's rules. Which two are they? What do they mean?
Why is the other one incorrect?
\ttbegin
'.77pt
"Ccc
-.sp
\ttend
\answer The first is not allowed, since octal notation cannot be used with
a decimal point. The second is, however, legal, since a \<number> can be
hexadecimal according to the rule mentioned in Chapter@8; it means
$\rm12{cc}$, which is $\rm144{dd}\approx154.08124{pt}$. The third is also
accepted, since a \<digit string> can be empty; it is a complicated
way to say $\rm0{sp}$.

The following ``rulers'' have been typeset by \TeX\ so that you can get
some idea of how different units compare to each other. If no distortion 
had been introduced during the camera work and printing processes that
took place after \TeX\ did its work, these rulers would be highly accurate.
$$ \dispskip 12pt plus 4pt minus 4pt
\vbox{
\def\1{\vrule height 0pt depth 2pt}
\def\2{\vrule height 0pt depth 4pt}
\def\3{\vrule height 0pt depth 6pt}
\def\4{\vrule height 0pt depth 8pt}
\def\ruler#1#2#3{\ljustline{$\vcenter{\hrule\hbox{\4#1}}\quad\rm#2{#3}$}}
\def\\#1{\hbox to .125in{\hfil#1}}
\def\8{\\\1\\\2\\\1\\\3\\\1\\\2\\\1\\\4}
\ruler{\8\8\8\8}4{in}
\vskip 12pt
\def\\#1{\hbox to 10pt{\hfil#1}}
\def\8{\\\1\\\1\\\1\\\1\\\2\\\1\\\1\\\1\\\1\\\4}
\ruler{\8\8\8}{300}{pt}
\vskip 12pt
\def\\#1{\hbox to 10dd{\hfil#1}}
\def\8{\\\1\\\1\\\1\\\1\\\2\\\1\\\1\\\1\\\1\\\4}
\ruler{\8\8\8}{300}{dd}
\vskip 12pt
\def\\#1{\hbox to 5mm{\hfil#1}}
\def\8{\\\2\\\4}
\ruler{\8\8\8\8\8\8\8\8\8\8}{10}{cm}
\vskip 6pt}$$

\dangerexercise (To be worked after you know about boxes and glue and have
read Chapter@21.) \ Explain how to typeset such a $\rm10{cm}$ ↑{ruler},
using \TeX.
\answer {\obeylines|\def\tick#1{\vrule height 0pt depth #1pt}|
|\def\\{\hbox to 1cm{\hfil\tick4\hfil\tick8}}|
|\vbox{\hrule\hbox{\tick8\\\\\\\\\\\\\\\\\\\\}}|
\noindent(You might also try putting ticks at every millimeter, in order %
to see how good your system is; %
some output devices can't handle 101@rules all at once.)}

\danger \TeX\ represents all dimensions internally as an integer multiple
of the tiny units called sp. Since the wavelength of visible light is
approximately $\rm100{sp}$, % in fact: violet=75sp, red=135sp!
rounding errors of a few sp make no difference to the eye.
However, \TeX\ does all of its arithmetic very carefully so that
identical results will be obtained on different computers. Different
implementations of \TeX\ will produce the same line breaks and the same
page breaks when presented with the same document, because the integer
arithmetic will be the same.
↑(machine-independence) ↑(rounding)

\danger The units have been defined here so that precise conversion to@sp
is@efficient on a wide variety of machines. In order to achieve this,
\TeX's ``pt'' has been made slightly larger than the official printer's
point, which was defined to equal exactly $\rm.013837{in}$ by the American
Typefounders Association in@1886 [cf.@National Bureau of Standards
Circular@570 (1956)]. In fact, one classical point is exactly
$.99999999\pt$, so the ``error'' is essentially one part in $10↑8$.
This is more than two orders of magnitude less than the amount by which
the inch itself changed during 1959, when it shrank to $\rm2.54{cm}$ from
its former value of $\rm(1/0.3937){cm}$; so there is no point in worrying
about the difference. The new definition $\rm72.27{pt}=1{in}$ is not only
better for calculation, it@is also easier to remember.

\danger \TeX\ will not deal with dimensions whose absolute value is
$\rm2↑{30}{sp}$ or more. In other words, the ↑{maximum legal dimension} is
slightly less than $16384\pt$. This is a distance of about 18.892 feet
(5.7583 meters); so it won't cramp your style.

In a language manual like this it is convenient to use ``↑{angle brackets}''
in abbreviations for various constructions like \<number> and \<optional
sign> and \<digit string>. Henceforth we shall use the term ↑{<dimen} to
stand for a legitimate \TeX\ dimension. For example,
$$\displaybox{|\hsize=|\<dimen>}$$
will be the general way to define the column width that \TeX\ is supposed
to use. The idea is that \<dimen> can be replaced by any quantity like
`|4in|' that satisfies \TeX's grammatical rules for dimensions;
abbreviations in angle brackets make it easy to state such laws of grammar.

When a dimension is zero, you have to specify a unit of measure even
though the unit is irrelevant. Don't just say `|0|'\thinspace; say `|0pt|' or
`|0in|' or something.

\smallbreak
The 10-point size of type that you are now reading is normal in textbooks,
but you probably will often find yourself wanting a larger font. Plain \TeX\
makes it easy to do this by providing {\magnifiedfiverm ↑{magnif{}ied
output}}. If you say
\ttbegin
\magnify{1200}
\ttend
at the beginning of your manuscript, everything will be enlarged by 20\%;
i.e., it will come out at 1.2 times the normal size. Similarly,
`|\magnify{2000}|' doubles everything; this actually quadruples the area of
each letter, since heights and widths are both doubled. To magnify a
document by the factor $f$, you say ↑{:magnify}|{|$n$|}|, where $n$@is
1000@times@$f$. This instruction must be given before the first page of output
has been completed. You cannot apply two different magnifications to the same
document.

Magnification has obvious advantages: You'll have less ↑{eyestrain} when
you're ↑{proofreading}; you can easily make ↑{transparencies} ↑(slides)
for lectures; and you can photo-reduce magnified output, in order to minimize
the deficiencies of a ↑{low-resolution printer}. Conversely, you might
even want to say `|\magnify{500}|' in order to create a ↑{pocket-size}
version of some book. ↑(squint print) But there's a slight catch:
You can't use magnification unless your printing device happens to have the
fonts that you need at the magnification you desire. In other words, you need
to find out what sizes are available before you can |\magnify|. Most
installations of \TeX\ make it possible to print all the fonts of plain
\TeX\ at three or more different magnifications, but the use of large fonts
can be expensive.

\exercise Try printing the short story of Chapter 6 at 1.2, 1.5, and 2.0
times the normal size. What should you type to get \TeX\ to do this?
\answer For example, say `|\magnify{1200} \input story \end|'. Three
separate runs are needed, since there can be at most one magnification
per job. The output may look funny if the fonts don't exist at the
stated magnifications.

\danger When you say |\magnify{2000}|, an operation like `|\vskip.5cm|' will
actually skip $\rm1.0{cm}$ of space in the final document. If you
want to specify a dimension in terms of the final size, \TeX\ allows
you to say `↑{.true}' just before |pt|, |pc|, |in|, |bp|, |cm|, |mm|,
|dd|, |cc|, and |sp|.  This unmagnifies the units, so that the subsequent
magnification will cancel out. For example, `|\vskip.5truecm|' is
equivalent to `|\vskip.25cm|' if you have previously said
`|\magnify{2000}|'. Plain \TeX\ uses this feature in the |\magnify|
command itself: Appendix@B includes the instruction
\ttbegin
\hsize = 6.5 true in
\ttend
just after a new magnification has taken effect. This adjusts the line width
so that the material on each page will be $6{1\over2}$ inches wide when it
is finally printed, regardless of the magnification factor.
There will be an inch of margin at both left and right,
assuming that the paper is $8{1\over2}$ inches wide.

\danger If you use no `|true|' dimensions, \TeX's internal computations are not
affected by the presence or absence of magnification; line breaks and page
breaks will be the same, and the ↑{.dvi} file will change in only two places.
\TeX\ simply tells the output routine that you want a certain magnification,
and the output routine does the actual enlargement. 

\dangerexercise Chapter 4 mentions that fonts of different magnifications
can be used in the same job, by loading them `↑{.at}' different sizes.
Explain what fonts will be used when you say `|\magnify{1500}
\font\first=cmr10 at 12pt \font\second=cmr10 at 12truept|'.
\answer Font |\first| will be cmr10 at $18\pt$ after magnification;
font |\second| will be cmr10 at $12\pt$. \ (\TeX\ changes
`|12truept|' into `|8pt|', and the final output magnifies it back to
$12\pt$.)

\ddanger Magnification is actually governed by \TeX's ↑{*mag} primitive,
which is an integer parameter that should be positive and at@most@32768.
The value of |\mag| is examined in three cases: (1)@just before the
first page is shipped to the |dvi| file; (2)@when computing a |true|
dimension; (3)@when the |dvi| file is being closed. Alternatively,
some implementations of \TeX\ produce non-|dvi| output; they examine
|\mag| in case@(2) and when shipping out each page. The value of |\mag|
must not change after it has first been examined.

\danger Sometimes \TeX's built-in units (|pt|, |cm|, etc\null.) aren't
really right for your application. You can always make up a new unit
of measure by saying
$$\displaybox{|\varunit=|\<dimen>}$$
after which you can give dimensions in `↑{.vu}'. For example, after
`↑{*varunit}|=.111111pt|', the instruction `|\vskip 2.5vu|' will skip
vertically by $2.777775\pt$. \TeX\ also recognizes two other
context-dependent units of measure:
$$\halign{\indent#\hfil\cr
|em| is the width of a ``quad'' in the current font;\cr
|ex| is the ``x-height'' of the current font.\cr}$$
↑(.em) ↑(quad) ↑(ex) ↑(x-height)
Each font defines its own em and ex values. In olden days, an ``em'' was
the width of an `M', but this is no longer true; ems are simply arbitrary
units that come with a font, and so are exes.  The Computer Modern fonts
have the property that an em-dash is one em wide, each of the ↑{digits} 0
to@9 is half an em wide, and lower case `x' is one ex high; but these are
not hard-and-fast rules for all fonts.
The |\rm| font (↑{.cmr10}) of plain \TeX\ has $\rm1{em}=10{pt}$
and $\rm1{ex}\approx4.3{pt}$; the |\bf| font (↑{.cmbx10}) has
$\rm1{em}=11.5{pt}$ and $\rm1{ex}\approx4.44{pt}$; and the |\tt| font
(↑{.cmtt}) has $\rm1{em}=10.5{pt}$ and $\rm1{ex}\approx4.3{pt}$. All of
these are ``10-point'' fonts, yet they have different em and ex values.
It@is generally best to use |em| for horizontal measurements and |ex| for
vertical measurements that depend on the current font.

\danger \TeX\ has several families of internal registers that we will be
discussing later; for now it will suffice to give a hint about what is
to@come. A \<dimen> can depend on \TeX's registers if one of the following
codes is used instead of a unit of measure:
$$\halign{\indent{\tt#}\<number> refers to the current &#\hfil\cr
dm&value of a |\dimen| register;\cr
ht&height of a |\box| register;\cr
wd&width of a |\box| register;\cr
dp&depth of a |\box| register.\cr}$$
↑(.dm) ↑(*dimen) ↑(.ht) ↑(.wd) ↑(.dp) ↑(*box) ↑(registers) ↑(*count)
For example, if $\hbox{|\count20|}=5$ and $\hbox{|\dimen5|}=30\pt$,
then `|\vskip 1.5dm\count20|' will skip vertically by $45\pt$.
You can use |ht|, |wd|, |dp| to make decisions based on the sizes of boxes;
for example, `|.5wd3|' is half the width of |\box3|.

\danger Notice that the unit names in dimensions
are not preceded by backslashes. The same is true of other so-called
↑{keywords} of the \TeX\ language. Keywords can be given in upper case letters
or in a mixture of upper and lower case; e.g., `|Pt|' is equivalent to `|pt|'.
\TeX\ gives a special interpretation to keywords only when they
appear in certain very restricted contexts. For example, `|pt|' is a
keyword only when it appears after a number in a \<dimen>;
`|at|' is a keyword only when it appears after the external name of a
font in a |\font| declaration.
Here is a complete list of \TeX's keywords, in case you are wondering about
the full set: |after|, |at|, |bp|, |by|, |cc|, |cm|, |dd|, |depth|, |dm|,
|dp|, |em|, |ex|, |expand|, |fil|, |fill|, |filll|, |for|, |height|, |ht|,
|in|, |minus|, |mm|, |mu|, |pc|, |plus|, |pt|, |sp|, |to|, |true|, |vu|,
|wd|, |width|.
See Appendix@I for references to the contexts in which each of these is
recognized as a keyword.

\danger A \<dimen> can also refer to \TeX's dimension or glue parameters.
For example, `|\the\hsize|' stands for the current value of |\hsize|;
`|\the\baselineskip|', when used in the context of a \<dimen>,
stands for the current |\baselineskip|,
ignoring its stretchability or shrinkability. Full details about
`↑{*the}' will be explained later.

\chapterend

The methods that have hitherto been taken
to discover the measure of the Roman foot,
will, upon examination, be found so unsatisfactory, that
it is no wonder the learned are not yet agreed on that point.
$\ldots$
9 London inches are equal to 8,447 Paris inches.
\author MATTHEW ↑{RAPER}, in {\sl Philosophical Transactions\/} (1760)
% ``An Enquiry into the Measure of the {\sl Roman\/} Foot,''
% {\sl Philos.\ Trans.\ \bf51} (1760), 774--823.

\bigskip

\ifnum\sesame=\count0 \else\errmessage{Change the value of \string\sesame!}\fi%

Without the letter U,
units would be nits.
\author ↑{SESAME STREET}{↑(Children's Television Workshop)} (1970)

\eject